package com.oedtech.esl.service.nettyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *
 * 基站业务层的父类，用于创建一下公共属性和方法
 */
@Component
public class BsBaseService {
    public static ExecutorService executorService= Executors.newCachedThreadPool();
    @Autowired
    public Environment env;  //配置文件类，可用env.getProperty（key）获取配置文件参数值
    public static Map<String,Integer>eslSumMap=new HashMap<>();
    @Value("${channel_num}")
    protected int channelNum;   //每个基站信道数量
    @Value("${app_id}")
    protected int appID;      //标签appID


    public static BsBaseService bsBaseService;

    @PostConstruct
    public void init(){
        bsBaseService=this;
    }

    /**
     * 校验和算法
     * @param sz 需要校验的字节数组
     * @return 校验和字节
     */
    public static byte getSum(byte[] sz) {
        byte sum=0;                         //校验和
        for(int i=0;i<sz.length-1;i++){
            sum+=sz[i];
        }
        return sum;
    }




}
